#include "FoodBuilderComboB.h"
#include "FoodIceCream.h"
#include "FoodChicken.h"

#include "UI/ModRun/Output/FactoryOutput.h"

//套餐A是 冰淇淋+炸鸡套餐;
FoodBuilderComboB::FoodBuilderComboB(QString IceCreamName, QString ChickName)
{
    m_strIceCreamName = IceCreamName;
    m_strChickName = ChickName;
    m_listFood.clear();

    QString strOutput = "套餐B Builder 构造:" + m_strIceCreamName + m_strChickName;
    qDebug() << strOutput;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutput };
        pOutPut->OutPut(outList);
    }
}

FoodBuilderComboB::~FoodBuilderComboB()
{
    QString strOutput = "套餐B Builder 析构:" + m_strIceCreamName + m_strChickName;
    qDebug() << strOutput;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutput };
        pOutPut->OutPut(outList);
    }
}


// 通过 InterFaceFoodBuilder 继承
void FoodBuilderComboB::CreateFood(size_t uNum)
{
    QString strOutputStart = "套餐B Builder 创建Food开始: [" + QString::number(uNum) + "]";
    qDebug() << strOutputStart;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutputStart };
        pOutPut->OutPut(outList);
    }
    ///////////////////////////////////////////////////////////////////////////////
    for (size_t i = 0; i < uNum; i++)
    {
        std::shared_ptr<IFood> foodIceCream(new FoodIceCream(m_strIceCreamName));
        m_listFood.push_back(foodIceCream);
        std::shared_ptr<IFood> foodClicken(new FoodChicken(m_strChickName));
        m_listFood.push_back(foodClicken);
    }
    ///////////////////////////////////////////////////////////////////////////////
    QString strOutputEnd = "套餐B Builder 创建Food结束: [" + QString::number(uNum) + "]";
    qDebug() << strOutputEnd;
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutputEnd };
        pOutPut->OutPut(outList);
    }
}

std::list<std::shared_ptr<IFood>> FoodBuilderComboB::GetFoodItems()
{
    return m_listFood;
}
